/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */




package learn.round1A;


import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.Iterator;
import java.util.Scanner;

/**
 *
 * @author robit
 */
public class MakeitSmooth1 {
    int D,I,M,N;
    int [] pixs;
    MakeitSmooth1(int D,int I,int M,int N,int[] pixs){
        this.D=D;
        this.I=I;
        this.M=M;
        this.N=N;
        this.pixs=pixs;
    }
    int InsertionCost(int x,int y){
        int d = Math.abs(x-y);
        if(d<=M)return 0;
        if(M==0)return 255*3;        
        return (d-1)/M*I;
    }
    int changingCost(int x,int y){
        return Math.abs(x-y);
    }
    int getMinCost(){
        int mincost=D*(N-1);
        if(N==3){
            for(int i=0;i<=255;i++){
                for(int j=0;j<=255;j++){
                    int inscost = InsertionCost(i, j)+D;

                    int chgcost = changingCost(i, pixs[0])
                                  +changingCost(j, pixs[1]);
                    mincost=Math.min(chgcost+inscost, mincost);

                    chgcost = changingCost(i, pixs[0])
                                  +changingCost(j, pixs[2]);
                    mincost=Math.min(chgcost+inscost, mincost);

                    chgcost = changingCost(i, pixs[1])
                                  +changingCost(j, pixs[2]);
                    mincost=Math.min(chgcost+inscost, mincost);

                    for(int k=0;k<=255;k++){
                        chgcost = changingCost(i, pixs[0])
                                  +changingCost(j, pixs[1])
                                  +changingCost(k, pixs[2]);
                        inscost = InsertionCost(i, j)
                                      +InsertionCost(j, k);
                        mincost=Math.min(chgcost+inscost, mincost);
                    }
                }
            }
        }
        else if(N == 2)
        {
            for(int i=0;i<=255;i++){
                for(int j=0;j<=255;j++){
                    int inscost = InsertionCost(i, j);

                    int chgcost = changingCost(i, pixs[0])
                                  +changingCost(j, pixs[1]);
                    mincost=Math.min(chgcost+inscost, mincost);
                }
            }
        }else{
            mincost=0;
        }
        return mincost;
    }
    private static Scanner s = null;
    private static PrintWriter o = null;
    /**
    * calculate the answer
    */
    private static int reckon() {
        int D=Int();
        int I=Int();
        int M=Int();
        int N=Int();
        int [] pixs= new int[N];
        for(int i=0;i<N;i++){
            pixs[i]=Int();
        }

        return (new MakeitSmooth1(D, I, M, N, pixs)).getMinCost();
    }


    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws IOException {
        // TODO code application logic here

        try {
            //String filename="test";
            String prob="B";
            String filename=prob+"-small-practice";
            //String filename=prob+"-large-practice";

            s = new Scanner(
                    new BufferedReader(new FileReader(filename+".in")));
            //s.useLocale(Locale.US);
            o = new PrintWriter(
                    new BufferedWriter(new FileWriter(filename+".out")));

            // Determine input line number
            int lineNums = s.nextInt();

            for (int i = 1; i <= lineNums; i++) {
                o.println("Case #" + i + ": " + reckon());
            }
        } finally {
            s.close();
            o.close();
        }
    }


    private static int Int(){
        return s.nextInt();
    }
    private static long Long(){
        return s.nextLong();
    }
    private static String String(){
        return s.next();
    }

}
